<?php
namespace app\api\controller;
use support\Request;
use think\facade\Db;
class PddController extends Base
{
    public function getPddList(Request $request){
        $page=$request->input('page',1);
        $pageSize=$request->input('pageSize',10);
        $currentIndex=$request->input('currentIndex',0);
        $isReload=$request->input('isReload',0);
        $list=[];
        if($currentIndex==0){
            $client = new \GetPddGoodsSearch();
            $client->setVersion("v2.0.0");
            $res = $client->setParams([
                'page'=>$page,
                'pageSize'=>$pageSize,
                'activityTags'=>'[4]',
                'blockCatPackages'=>'[1,2,3,4,5]'
            ])->request();
            $res=json_decode($res,true);
        }
        if($currentIndex==1){
            $client = new \GetGoodsList();
            $client->setVersion("v1.2.4");
            $res = $client->setParams([
                'pageId'=>$page,
                'pageSize'=>$pageSize,
            ])->request();
            $res=json_decode($res,true);
        }
        if($res['code']==0){
            $list=$res['data'];
        }
        s($list);
    }

    public function getPddOne(Request $request){
        $goodsSign=$request->input('goodsSign','');
        $client = new \GetGoodsPromGenerate();
        $client->setVersion("v2.0.0");
        $res = $client->setParams([
            'pid'=>config('dtk.pddPid'),
            'goodsSign'=>$goodsSign
        ])->request();
        $res=json_decode($res,true);
        if($res['code']==0){
            $res=$res['data'];
        }
        s($res);
    }
    public function getTbOne(Request $request){
        $goodsId=$request->input('goodsId','');
        $client = new \GetPrivilegeLink();
        $client->setVersion("v1.3.1");
        $res = $client->setParams([
            'pid'=>config('dtk.taobaoPid'),
            'goodsId'=>$goodsId
        ])->request();
        $res=json_decode($res,true);
        if($res['code']==0){
            $res=$res['data'];
        }
        s($res);
    }
    public function getSuicai(Request $request){
        $pageId=$request->input('pageId',1);
        $client = new \GetTbTopicList();
        $client->setVersion("v1.2.0");
        $res = $client->setParams([
            'pageId'=>$pageId,
            'pageSize'=>5,
            'sort'=>2
        ])->request();
        $res=json_decode($res,true);
        if($res['code']==0){
            $res=$res['data'];
        }
        s($res);
    }

    public function getIndexList(Request $request){
        $page=$request->input('page',1);
        $pageSize=$request->input('pageSize',10);
        $client = new \GetListHeightCommission();
        $client->setVersion("v1.0.0");
        $res = $client->setParams([
            'pageId'=>$page,
            'pageSize'=>$pageSize,
            'sort'=>3
        ])->request();
        $res=json_decode($res,true);
        if($res['code']==0){
            $res=$res['data'];
        }
        s($res);
    }
}
